import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/basic_information/component_information_entity.dart';
import 'package:get/get.dart';

class PartsAccessoryDetailsController extends GetxController {
  /// id
  final String id = Get.arguments as String;

  /// 当前显示状态类型
  /// 类型（0，更换；1，校验)
  int type = 0;

  ///详情数据
  ComponentInformationEntity informationEntity = ComponentInformationEntity();

  @override
  void onInit() {
    super.onInit();
    initData();
  }

  ///初始化页面数据
  Future<void> initData() async {
    final res = await HttpUtil().generateGetRequest<ComponentInformationEntity>(
      Interface.getComponentInfo,
      queryParameters: {
        'id': id,
        'type': type,
      },
    ).execute();
    res.onSuccess((result) {
      if (result.data != null) {
        informationEntity = result.data!;
      }
    });
    update();
  }

  /// 点击状态切换
  void onClickType(int type) {
    this.type = type;
    initData();
  }
}
